const webhttp = (url,data,type='GET',showloading=false) =>{
	
	return new Promise((resolve,reject)=>{
		if(showloading){
			uni.showLoading({
				mask:true,
				title:"加载中..."
			});
		}
		uni.request({
			url: url,
			method: type,
			header: {
				"Content-Type": "application/x-www-form-urlencoded"
			},
			data: data,
			success: res => {
				resolve(res.data);
			},
			fail: (e) => {
				console.log(e);
				reject(e);
			},
			complete: () => {
				if(showloading){
					uni.hideLoading();
				}
				
			}
		});
	});
}

export default webhttp;